import { createRouter, createWebHashHistory } from "vue-router";
import adminLayout from "../layout/adminLayout.vue";

const base = [
  {
    path: "/",
    name: "root",
    component: () => import("../layout/content.vue"),
    redirect: "/login",
    meta: { layout: "blank" },
  },
  {
    path: "/login",
    name: "login",
    component: () => import("../views/login/index.vue"),
    meta: { layout: "blank" },
  },
];

const error = {
  path: "/:pathMatch(.*)*",
  name: "error",
  component: () => import("../views/error/index.vue"),
  meta: { layout: "blank" },
};

export const dynamic = [
  {
    path: "/front",
    name: "front",
    redirect: "/front/home",
    component: () => import("../views/front/base/index.vue"),
    children: [
      {
        path: "/front/home",
        name: "home",
        component: () => import("../views/front/home/index.vue"),
        meta: { layout: "content", title: "首页", icon: "build" },
      },
    ],
  },
];

export const admin = [
  {
    path: "/admin",
    name: "admin",
    redirect: "/admin/auth",
    component: adminLayout,
    meta: { layout: "blank", title: "后台管理" },
    children: [
      {
        path: "/admin/auth",
        name: "auth",
        redirect: "/admin/auth/user",
        meta: { title: "授权管理" },
        children: [
          {
            path: "/admin/auth/user",
            name: "user",
            component: () => import("../views/admin/user/index.vue"),
            meta: { title: "用户管理", icon: "build" },
          },
          {
            path: "/admin/auth/role",
            name: "role",
            component: () => import("../views/admin/role/index.vue"),
            meta: { title: "角色管理", icon: "build" },
          },
          {
            path: "/admin/auth/menu",
            name: "menu",
            component: () => import("../views/admin/menu/index.vue"),
            meta: { title: "菜单管理", icon: "build" },
          },
        ],
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: [...base],
});

export default router;
